package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Region;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationController {
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;
//    private
    @GetMapping("/hotRegion")
    public Object queryHotRegion(){
       List<Region> list =  regionService.queryHotRegion();
        return JsonResult.success(list);
    }

    @GetMapping("/search")
    public Object search(String regionId){
       List<Destination> list = destinationService.queryDestByRegionIdForApi(regionId);
        return JsonResult.success(list);
    }

    @GetMapping("/toasts")
    public Object toasts(String destId){
        List<Destination> list = destinationService.findByParentId(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = strategyCatalogService.findCatalogAndSubInfo(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){
        List<Strategy> list = strategyService.queryStrategyTop3(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelViewnumTop3(String destId){
        return JsonResult.success(travelService.queryTravelTop3(destId));
    }

    @GetMapping("/list")
    public Object list(){
        return JsonResult.success(destinationService.listAll());
    }



}
